<?php

declare(strict_types=1);

namespace app\index\controller;

use app\admin\controller\blackbox\Playerinfo;
use think\facade\Request;
use app\common\model\GmTclpanellc as lcMod;
use app\common\model\BlackboxPlayerinfo as boxPlayerinfo;
use app\common\model\ZadanPlayerinfo as zadanPlayerinfo;
use app\common\model\TrandingbankListsr as trandingMod;
use app\common\model\TrandingbankListsr as listM;
use think\facade\Config;

class Index extends \app\BaseController
{
    /**
     * 首页
     */
    public function index()
    {
        return $this->fetch();
    }

    public function hello($name)
    {
        $response = [
            'msg' => '操作成功',
            'code' => 200,
            'data' => $name,
        ];
        return json($response);
    }

    public function automaticLogin()
    {
        $response = [
            'url' => '127.0.0.1' . '?token=' . '123456789',
            'username' => '123123'
        ];
        $res = [
            'code' => 0, 'data' => $response, 'msg' => 'success',
        ];
        return json($res);
    }


    public function serverConfig()
    {
        $game = [
            'amplitude' => 1, //加减按钮幅度
            'bet_max' => 50000, //最大下注数
            'bet_min' => 50, //最小下注数
            'btn_bet' => '2, 5, 10, 20', // 投注额列表
            'channel' => 1011, //渠道
            'created_at' => time(), //创建时间
            'game_max' => 500000,

            'game_status' => 1, //游戏状态
            'id' => 1011, //创建时间
            'initial_bet' => 100, //初始下注额度
            'rule_content' => [5, 10, 500, 5000], //初始下注额度
            'settlement_max' => 500, ////最大结算倍数
            'settlement_min' => 50, ////最小结算倍数
            'system' => 0,
            'updated_at' => time(), //修改时间
        ];
        $server = [
            'address' => '127.0.0.1:3050', //前端wss地址
            'protocol' => 'ws', //ws  wss
        ];
        $response = [
            'currency' => 'USDT', //币种
            'game' =>  $game,
            'server' => $server,
            'tag' => 'U', //币种缩写
            'token' => '123456789', //Token
            'gameTag' => '1011', //游戏标识
        ];
        $res = [
            'code' => 0, 'data' => $response, 'msg' => 'success',
        ];
        return json($res);
    }

    //-----------------------------------------------------------  头筹活动
    //获取轮次列表
    public function getLuncils($type)
    {
        $response = [
            'msg' => '操作成功',
            'code' => 200,
            'data' => lcMod::getListWhere($type),
        ];
        return json($response);
    }
    //获取玩家平台币
    public function getPlayerRmb($account, $qufu)
    {
        $response = [
            'msg' => '操作成功',
            'code' => 200,
            'data' => lcMod::getPlayerRmb($account, $qufu)[0],
        ];
        return json($response);
    }

    //获取玩家6元卡数量
    public function getPlayer6yk($actorid, $qufu)
    {
        $response = [
            'msg' => '操作成功',
            'code' => 200,
            'data' => lcMod::getPlayer6yk($actorid, $qufu)[0],
        ];
        return json($response);
    }

    //我的历史记录
    public function getmylogls($account, $actorid, $qufu, $type)
    {
        $response = [
            'msg' => '操作成功',
            'code' => 200,
            'data' => lcMod::getmylogls($account, $actorid, $qufu, $type),
        ];
        return json($response);
    }
    //所有历史记录
    public function getalllogls($type)
    {
        $response = [
            'msg' => '操作成功',
            'code' => 200,
            'data' => lcMod::getalllogls($type),
        ];
        return json($response);
    }

    //获取轮次列表
    public function getCanyu($account, $actorid, $qufu, $lunciid)
    {
        $response = ['code' => 201,'msg' => '活动已关闭！！！'];
        return json($response);


        if ($account && $actorid && $qufu && $lunciid) {

            try {
                $llc =  lcMod::getIsCanyu($lunciid);
                $numpre = self::panelPre(intval($llc[0]["luncitype"]));

                if (intval($llc[0]["currentprenum"]) < $numpre) {
                    lcMod::getCanyu($account, $actorid, $qufu, $lunciid, $llc[0]["luncitype"]);
                } else if (intval($llc[0]["currentprenum"]) == $numpre) {
                    lcMod::getCanyu($account, $actorid, $qufu, $lunciid, $llc[0]["luncitype"]);
                    lcMod::updateCanyustatus($lunciid);
                } else {
                    $response = [
                        'code' => 201,
                        'msg' => '参赛人数已满！！！'
                    ];
                    return json($response);
                }
            } catch (\Throwable $th) {
                $response = [
                    'code' => 201,
                    'msg' => '参与失败！！！' . $th
                ];
                return json($response);
            }


            $response = [
                'msg' => '操作成功!',
                'code' => 200
            ];
            return json($response);
        } else {
            $response = [
                'code' => 201,
                'msg' => '数据不完整！'
            ];
            return json($response);
        }
    }

    function panelPre($panelIndex)
    {
        //-----------------------------------注意减1
        if ($panelIndex == 1) {
        } else if ($panelIndex == 2) {
            return 14;
        } else if ($panelIndex == 3) {
            return 14;
        } else if ($panelIndex == 4) {
            return 11;
        } else if ($panelIndex == 5) {
            return 7;
        }
        return null;
    }


    //-----------------------------------------------------------  盲盒活动
    //获取玩家平台币
    public function getPlayerConfig($actorid, $account, $qufu)
    {
        //默认是没有数据的，进来的第一时间先查询是否有玩家信息，没有就直接添加
        $userinfo = boxPlayerinfo::playerInfo($actorid, $account, $qufu);
        if (empty($userinfo)) {

            if ($actorid == 'undefined' || $account == 'undefined' || $qufu == 'undefined') {
                $response = [
                    'msg' => '操作失败，请使用正确账号！',
                    'code' => 201
                ];
                return json($response);
            }
            //actorid验证
            $nikename = boxPlayerinfo::actoridCheck($actorid, $account, $qufu);
            if (empty($nikename)) {
                $response = [
                    'msg' => '操作失败，请使用正确actorid！',
                    'code' => 201
                ];
                return json($response);
            }
            boxPlayerinfo::addPlayer($actorid, $account, $qufu, $nikename);
            // 手动组装数据
            $userinfo = [
                'actorid' => $actorid,
                'account' => $account,
                'qufu' => $qufu,
                'opennum' => 0,
                'cjcoin' => 0,
                'isdefaultcoin' => 1,
            ];
        } else {
            $userinfo = $userinfo[0]; // 如果不为空，则取第一个元素
        }

        $userinfo["ptb"] = boxPlayerinfo::getPTBNum($account, $qufu); //增加一个平台币
        $response = [
            'msg' => '操作成功',
            'code' => 200,
            'data' =>
            [
                'playerinfo' => $userinfo,
                'gameconfig' => boxPlayerinfo::configInfo()
            ]
        ];
        return json($response);
    }

    //开盲盒
    public function openBlackbox($actorid, $account, $qufu, $opennum)
    {
        //判断金币是否足够
        $userinfo = boxPlayerinfo::playerInfo($actorid, $account, $qufu)[0];
        $gameconfig = boxPlayerinfo::configInfo();

        if (!in_array($opennum, explode(',', $gameconfig["typels"]))) {
            $response = [
                'msg' => '有这找bug的耐心，干什么不赚钱？来这里秀智商？',
                'code' => 201
            ];
            return json($response);
        }

        $xiaohaocoin = $opennum * $gameconfig["onenumcoin"];

        if ($userinfo["cjcoin"] < $xiaohaocoin) {
            $response = [
                'msg' => '金币不足',
                'code' => 201
            ];
            return json($response);
        }

        if ($gameconfig["activiteisopen"] == 0) {
            $response = [
                'msg' => '活动未开启！',
                'code' => 201
            ];
            return json($response);
        }

        $items = boxPlayerinfo::getRewardgoodsItems();
        $winners = [];
        $itemsInfo = []; // 用于记录抽中的物品的完整信息

        // 执行多次抽奖
        for ($i = 0; $i < $opennum; $i++) {
            $item = self::lottery($items);
            // 将抽中的物品添加到中奖者数组中
            if (isset($winners[$item["name"]])) {
                $winners[$item["name"]] += 1 * $item["num"];
            } else {
                $winners[$item["name"]] = 1 * $item["num"];
            }
            $item["cjnum"] = $winners[$item["name"]];
            // 检查是否已经存在相同的物品，如果是，则更新其 cjnum 值
            $found = false;
            foreach ($itemsInfo as &$existingItem) {
                if ($existingItem["goodsid"] === $item["goodsid"]) {
                    $existingItem["cjnum"] += $item["num"];
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                $itemsInfo[] = $item;
            }
        }

        $nowcoin = $userinfo["cjcoin"] - $xiaohaocoin;
        $response = [
            'msg' => boxPlayerinfo::consumeCoin($actorid, $account, $qufu, $xiaohaocoin, $userinfo["cjcoin"], $opennum, $winners),
            'code' => 200,
            'test' => $itemsInfo,
            'nowcoin' => $nowcoin,
            // 'sql' => boxPlayerinfo::sendEmail($qufu, $actorid, $itemsInfo, "盲盒抽取奖励发放"),
            'data' => $winners // 返回所有中奖物品及其对应的数量
        ];
        boxPlayerinfo::sendEmail($qufu, $actorid, $itemsInfo, "盲盒抽取奖励发放");
        return json($response);
    }

    // 定义抽奖函数
    public function lottery($items)
    {
        // 初始化总权重
        $totalWeight = 0;

        // 计算总权重
        foreach ($items as $item) {
            $totalWeight += $item['dropnum'];
        }

        // 生成一个随机数，范围在 1 到总权重之间
        $rand = mt_rand(1, $totalWeight);

        // 根据随机数确定中奖物品
        foreach ($items as $item) {
            $rand -= $item['dropnum'];
            if ($rand <= 0) {
                return $item;
            }
        }

        // 如果出现意外情况，返回空值
        return null;
    }

    //获取榜单
    public function getBroad($actorid, $account, $qufu, $type)
    {
        $todayDate = date('Y-m-d');


        if ($type == 'day') {
            $currPlayerRank = boxPlayerinfo::getPlayerRank($account, $actorid, $qufu, $todayDate);
            $broad = boxPlayerinfo::getBroad($qufu, $todayDate);
        } else {
            $currPlayerRank = boxPlayerinfo::getPlayerRank($account, $actorid, $qufu);
            $broad = boxPlayerinfo::getBroad($qufu);
        }


        $response = [
            'msg' => '操作成功',
            'code' => 200,
            'currPlayerRank' => $currPlayerRank,
            'data' => $broad,
        ];
        return json($response);
    }

    //发送排行奖励
    public function sendRankBroad($type, $pwd)
    {
        if ($pwd != "iMdWZ5enYJxmwpFG") {
            $response = [
                'msg' => '操作失败',
                'code' => 201
            ];
            return json($response);
        }

        if ($type == "all") {
            $response = [
                'msg' => '操作成功',
                'code' => 200,
                'data' => boxPlayerinfo::sendReward("all"),
            ];
            return json($response);
        }
        if ($type == "day") {
            $response = [
                'msg' => '操作成功',
                'code' => 200,
                'data' => boxPlayerinfo::sendReward("day"),
            ];
            return json($response);
        }
    }

    //超级金币充值11
    public function rechargePtb($actorid, $account, $qufu, $num)
    {

        $response = [
            'msg' => '兑换已关闭，请稍后再试！',
            'code' => 201
        ];
        return json($response);
        //获取兑换比例
        $gameconfig = boxPlayerinfo::configInfo();
        $userinfo = boxPlayerinfo::playerInfo($actorid, $account, $qufu)[0];
        $dhbl = explode(":", $gameconfig["dhbl"])[1];

        //获取玩家平台币
        $playerptb = boxPlayerinfo::getPTBNum($account, $qufu);

        $needptbnum = intval($dhbl) * intval($num); //需要多少平台币

        if ($needptbnum > intval($playerptb)) {
            $response = [
                'msg' => '操作失败，平台币不足！',
                'code' => 201
            ];
            return json($response);
        }
        if ($gameconfig["activiteisopen"] == 0) {
            $response = [
                'msg' => '活动未开启！',
                'code' => 201
            ];
            return json($response);
        }

        //执行扣减增加
        $playerptb = boxPlayerinfo::duihuanCjcoin($account, $actorid, $qufu, $num, $needptbnum, $userinfo["cjcoin"], $playerptb);

        $response = [
            'msg' => '操作成功',
            'code' => 200,
            'ptb' =>  boxPlayerinfo::getPTBNum($account, $qufu),
            'nowcoin' => ($num + $userinfo["cjcoin"])
        ];
        return json($response);
    }

    //获取url和是否开启盲盒  http://101.33.245.40:7999/index.php/     
    public function getcocosurl()
    {
        $gameconfig = boxPlayerinfo::configInfo();

        if ($gameconfig["activiteisopen"] == 1) {
            $response = [
                'msg' => '操作成功！',
                'code' => 200,
                'activiteisopen' => 1,
                'url' => '../cocos1/index.html'
            ];
        } else {
            $response = [
                'msg' => ' 操作成功！',
                'code' => 200,
                'activiteisopen' => 0
            ];
        }
        return json($response);
    }

    //-----------------------------------------------------------  砸蛋活动
    public function getZadanPlayerConfig($actorid, $account, $qufu)
    {
        //默认是没有数据的，进来的第一时间先查询是否有玩家信息，没有就直接添加
        $userinfo = zadanPlayerinfo::playerInfo($actorid, $account, $qufu);
        if (empty($userinfo)) {

            if ($actorid == 'undefined' || $account == 'undefined' || $qufu == 'undefined') {
                $response = [
                    'msg' => '操作失败，请使用正确账号！',
                    'code' => 201
                ];
                return json($response);
            }
            //actorid验证
            $nikename = zadanPlayerinfo::actoridCheck($actorid, $account, $qufu);
            if (empty($nikename)) {
                $response = [
                    'msg' => '操作失败，请使用正确actorid！',
                    'code' => 201
                ];
                return json($response);
            }
            zadanPlayerinfo::addPlayer($actorid, $account, $qufu, $nikename);
            // 手动组装数据
            $userinfo = [
                'actorid' => $actorid,
                'account' => $account,
                'qufu' => $qufu,
                'opennum' => 0,
                'cjcoin' => 0,
                'isdefaultcoin' => 1,
            ];
        } else {
            $userinfo = $userinfo[0]; // 如果不为空，则取第一个元素
        }

        $userinfo["ptb"] = zadanPlayerinfo::getPTBNum($account, $qufu); //增加一个平台币
        $response = [
            'msg' => '操作成功',
            'code' => 200,
            'data' =>
            [
                'playerinfo' => $userinfo,
                'gameconfig' => zadanPlayerinfo::configInfo()
            ]
        ];
        return json($response);
    }

    //超级金币充值11
    public function zadanrechargePtb($actorid, $account, $qufu, $num)
    {
        //获取兑换比例
        $gameconfig = zadanPlayerinfo::configInfo();
        $userinfo = zadanPlayerinfo::playerInfo($actorid, $account, $qufu)[0];
        $dhbl = explode(":", $gameconfig["dhbl"])[1];

        //获取玩家平台币
        $playerptb = zadanPlayerinfo::getPTBNum($account, $qufu);

        $needptbnum = intval($dhbl) * intval($num); //需要多少平台币

        if ($needptbnum > intval($playerptb)) {
            $response = [
                'msg' => '操作失败，平台币不足！',
                'code' => 201
            ];
            return json($response);
        }
        if ($gameconfig["activiteisopen"] == 0) {
            $response = [
                'msg' => '活动未开启！',
                'code' => 201
            ];
            return json($response);
        }

        //执行扣减增加
        $playerptb = zadanPlayerinfo::duihuanCjcoin($account, $actorid, $qufu, $num, $needptbnum, $userinfo["cjcoin"], $playerptb);

        $response = [
            'msg' => '操作成功',
            'code' => 200,
            'ptb' =>  zadanPlayerinfo::getPTBNum($account, $qufu),
            'nowcoin' => ($num + $userinfo["cjcoin"])
        ];
        return json($response);
    }

    //开盲盒
    public function zadan($actorid, $account, $qufu, $opennum)
    {
        //判断金币是否足够
        $userinfo = zadanPlayerinfo::playerInfo($actorid, $account, $qufu)[0];
        $gameconfig = zadanPlayerinfo::configInfo();

        if (!in_array($opennum, explode(',', $gameconfig["typels"]))) {
            $response = [
                'msg' => '有这找bug的耐心，干什么不赚钱？来这里秀智商？',
                'code' => 201
            ];
            return json($response);
        }

        $xiaohaocoin = $opennum * $gameconfig["onenumcoin"];

        if ($userinfo["cjcoin"] < $xiaohaocoin) {
            $response = [
                'msg' => '金币不足',
                'code' => 201
            ];
            return json($response);
        }
        if ($gameconfig["activiteisopen"] == 0) {
            $response = [
                'msg' => '活动未开启！',
                'code' => 201
            ];
            return json($response);
        }

        $items = zadanPlayerinfo::getRewardgoodsItems();
        $winners = [];
        $itemsInfo = []; // 用于记录抽中的物品的完整信息

        // 执行多次抽奖
        for ($i = 0; $i < $opennum; $i++) {
            $item = self::lottery($items);
            // 将抽中的物品添加到中奖者数组中
            if (isset($winners[$item["name"]])) {
                $winners[$item["name"]] += 1 * $item["num"];
            } else {
                $winners[$item["name"]] = 1 * $item["num"];
            }
            $item["cjnum"] = $winners[$item["name"]];
            // 检查是否已经存在相同的物品，如果是，则更新其 cjnum 值
            $found = false;
            foreach ($itemsInfo as &$existingItem) {
                if ($existingItem["goodsid"] === $item["goodsid"]) {
                    $existingItem["cjnum"] += $item["num"];
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                $itemsInfo[] = $item;
            }
        }

        $nowcoin = $userinfo["cjcoin"] - $xiaohaocoin;
        $response = [
            'msg' => zadanPlayerinfo::consumeCoin($actorid, $account, $qufu, $xiaohaocoin, $userinfo["cjcoin"], $opennum, $winners),
            'code' => 200,
            'test' => $itemsInfo,
            'nowcoin' => $nowcoin,
            // 'sql'=>zadanPlayerinfo::sendEmail($qufu, $actorid, $itemsInfo, "盲盒抽取奖励发放"),
            'data' => $winners // 返回所有中奖物品及其对应的数量
        ];
        zadanPlayerinfo::sendEmail($qufu, $actorid, $itemsInfo, "砸蛋奖励发放");
        return json($response);
    }

    //获取url和是否开启  http://101.33.245.40:7999/index.php/     
    public function getzadancocosurl()
    {
        $gameconfig = zadanPlayerinfo::configInfo();

        if ($gameconfig["activiteisopen"] == 1) {
            $response = [
                'msg' => '操作成功！',
                'code' => 200,
                'activiteisopen' => 1,
                'url' => '../cocos/zadan/index.html'
            ];
        } else {
            $response = [
                'msg' => ' 操作成功！',
                'code' => 200,
                'activiteisopen' => 0
            ];
        }
        return json($response);
    }



    //外置装备合成
    public function getwzConfighecheng()
    {
        $response = [
            'msg' => ' 操作成功！',
            'code' => 200,
            'data' => config('hechengConfig'),
        ];
        return json($response);
    }


    //-------------------------------------------------------- 交易行相关

    //获取售卖列表
    public function getShellList($actorid, $serverid)
    {
        return json(trandingMod::getShellList($actorid, $serverid));
    }

    public function getbuylList($actorid, $serverid)
    {
        return json(trandingMod::getbuylList($actorid, $serverid));
    }


    public function getmyShellList($actorid, $serverid)
    {
        return json(trandingMod::getmyShellList($actorid, $serverid));
    }

    public function getmybuylList($actorid, $serverid)
    {
        return json(trandingMod::getmybuylList($actorid, $serverid));
    }

    public function removeItem($id)
    {
        $handingdata = trandingMod::checkStatus($id);
        if ($handingdata["goodstatus"] != 1) {
            return json(['msg' => '状态无需修改！', 'code' => 201]);
        }

        $serverid = $handingdata["shellplayserverid"];
        $actorid = $handingdata["shellplayactorid"];
        $names = $handingdata["shellgoodsname"];
        $idstr = '1,' . $handingdata["shellgoodsid"] . ',' . $handingdata["shellgoodsnum"];

        //修改状态
        trandingMod::moStatus($id);
        //发送邮件
        trandingMod::sendMail($serverid, $actorid, $names, $idstr);
        return json(['msg' => '下架成功', 'code' => 200]);
    }
    
    public function gethandingconfig()
    {
        $data = listM::getGoodsls();
        // 返回JSON响应
        return json(['msg' => '操作成功', 'data' => $data, 'code' => 1]);

        // // 测试服配置路径
        // $path1 = "/data/mu_s3/gameworld/data/config/dazao/handingBank.lua";

        // // 检查文件是否存在
        // if (!file_exists($path1)) {
        //     return json(['msg' => '文件不存在！', 'code' => 2]);
        // }

        // // 读取Lua文件内容
        // $luaContent = file_get_contents($path1);

        // // 移除注释
        // $luaContent = $this->removeLuaComments($luaContent);

        // // 解析Lua文件内容
        // $config = $this->parseLuaConfig($luaContent);

        // // 清理配置内容中的特殊字符
        // $cleanConfig = $this->cleanConfig($config);

        // // 将配置转换为JSON格式，并确保使用 JSON_UNESCAPED_UNICODE 和 JSON_UNESCAPED_SLASHES 选项
        // $jsonConfig = json_encode($cleanConfig, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);

        // // 返回JSON响应
        // return json(['msg' => '操作成功', 'data' => json_decode($jsonConfig), 'code' => 1]);
    }

    private function removeLuaComments($luaContent)
    {
        // 移除单行注释 -- 以及后面的内容
        $luaContent = preg_replace('/--.*$/m', '', $luaContent);

        // 移除多行注释 --[[]]中的内容
        $luaContent = preg_replace('/--\[\[(.|\s)*?\]\]/', '', $luaContent);

        return $luaContent;
    }

    private function parseLuaConfig($luaContent)
    {
        // 初始化配置数组
        $config = [];

        // 匹配每个配置块
        preg_match_all('/\[(\d+)\] = \{([^}]+)\}/', $luaContent, $matches, PREG_SET_ORDER);

        foreach ($matches as $match) {
            $id = $match[1];
            $properties = $match[2];

            // 初始化配置项
            $config[$id] = [];

            // 匹配每个属性
            preg_match_all('/(\w+) = ([^,]+),?/', $properties, $propMatches, PREG_SET_ORDER);

            foreach ($propMatches as $propMatch) {
                $key = $propMatch[1];
                $value = $propMatch[2];

                // 移除引号并转换为合适的类型
                $value = trim($value, "'");

                if (is_numeric($value)) {
                    $value = $value + 0; // 转换为数字
                }

                $config[$id][$key] = $value;
            }
        }

        return $config;
    }

    private function cleanConfig($config)
    {
        // 遍历配置数组，清理每个字符串中的特殊字符
        foreach ($config as &$item) {
            foreach ($item as $key => $value) {
                if (is_string($value)) {
                    // 去除字符串中的换行符、回车符和首尾的空格
                    $item[$key] = trim(preg_replace('/\s+/', ' ', $value));
                }
            }
        }
        return $config;
    }



    //道具购买
    public function buygoodls($account, $qufu, $actorid, $tcchoose)
    {
        $data = [
            'tc1' => [
                'tcname' => '礼包1',
                'price' => 1000000,
                'goodsls' => [
                    ['goodsid' => '700000', 'name' => '元素能量丹', 'cjnum' => '10000'],
                    ['goodsid' => '368000', 'name' => '神迹能量丹', 'cjnum' => '10000'],
                    ['goodsid' => '368100', 'name' => '异火能量丹', 'cjnum' => '10000']
                ]
            ],
            'tc2' => [
                'tcname' => '礼包2',
                'price' => 5500000,
                'goodsls' => [
                    ['goodsid' => '450025', 'name' => '新年烟花', 'cjnum' => '629500'],
                    ['goodsid' => '640029', 'name' => '鞭炮', 'cjnum' => '210000']
                ]
            ]
        ];
        //获取玩家平台币
        $playerptb = zadanPlayerinfo::getPTBNum($account, $qufu);

        $needptbnum = $data[$tcchoose]["price"]; //需要多少平台币

        if ($needptbnum > intval($playerptb)) {
            $response = [
                'msg' => '操作失败，平台币不足！',
                'code' => 201
            ];
            return json($response);
        }

        zadanPlayerinfo::koujianRmb($account, $qufu, $needptbnum, $playerptb, $data[$tcchoose]["tcname"] . "购买");
        zadanPlayerinfo::sendEmail($qufu, $actorid, $data[$tcchoose]["goodsls"], $data[$tcchoose]["tcname"] . "购买");
        $response = [
            'msg' => '操作成功！',
            'code' => 200,
        ];
        return json($response);
    }
}
